package com.sxt.sys.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.support.PagedListHolder;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sxt.sys.domain.Notice;
import com.sxt.sys.mapper.NoticeMapper;
import com.sxt.sys.service.NoticeService;
import com.sxt.sys.utils.DataGridView;
import com.sxt.sys.utils.WebUtils;
import com.sxt.sys.vo.NoticeVo;
@Service
public class NoticeServiceImpl implements NoticeService{
	@Autowired
	private NoticeMapper noticeMapper;
	
	
	@Override
	public DataGridView queryAllNotice(NoticeVo NoticeVo) {
		Page<Object> page = PageHelper.startPage(NoticeVo.getPage(),NoticeVo.getLimit());
		List<Notice> data = noticeMapper.queryAllNotice(NoticeVo);
		return new DataGridView(page.getTotal(),data);
	}


	@Override
	public Integer addNotice(NoticeVo noticeVo) {
		// TODO Auto-generated method stub
		noticeVo.setCreatetime(new Date());
		noticeVo.setOpername(WebUtils.getCurrentUser().getName());
		return noticeMapper.insertSelective(noticeVo);
	}


	@Override
	public Integer deleteNotice(Integer id) {
		// TODO Auto-generated method stub
		return noticeMapper.deleteByPrimaryKey(id);
	}


	@Override
	public Integer updateNotice(NoticeVo noticeVo) {
		// TODO Auto-generated method stub
		return noticeMapper.updateByPrimaryKeySelective(noticeVo);
	}


	@Override
	public Notice loadNoticeById(Integer id) {
		// TODO Auto-generated method stub
		return noticeMapper.selectByPrimaryKey(id);
	}

}
